package com.itheima02;

import java.math.BigDecimal;
import java.util.Arrays;

public class Work01 {
    public static void main(String[] args) {
        double[] arr = {0.1, 0.2, 2.1, 3.2, 5.56, 7.21};
        double sum = 0;
        for (int i = 0; i < arr.length; i++) {
            sum += arr[i];
        }
        System.out.println("总值为:" + sum);

        BigDecimal b1 = new BigDecimal(sum);
        BigDecimal b2 = new BigDecimal(arr.length);
        BigDecimal b3 = b1.divide(b2, 2, BigDecimal.ROUND_HALF_DOWN);

        System.out.println("平均值为" + b3);
    }
}
